package job

import (
	"code.bydev.io/cht/customer/kyc_admin_service/internal/utils/middleware"
	"git.bybit.com/svc/stub/pkg/pb/api/ban"

	"code.bydev.io/frameworks/byone/zrpc"
)

// RPCConfig rpc server连接配置信息，格式：domain+grpc service name+Access
type RPCConfig struct {
	BanServicePrivateAccess zrpc.RpcClientConf // 封禁
}

// RPCClient rpc client，格式：domain+grpc service name, 如：财务ServiceOuterAPI-FinanceServiceOuterAPI
type RPCClient struct {
	BanServicePrivateAPI ban.BanInternalClient // 封禁
}

func InitRPC(rc *RPCConfig) *RPCClient {
	clientInterceptors := []zrpc.ClientOption{zrpc.WithUnaryClientInterceptor(middleware.LogClientInterceptor)}
	return &RPCClient{
		BanServicePrivateAPI: ban.NewBanInternalClient(zrpc.MustNewClient(rc.BanServicePrivateAccess, clientInterceptors...).Conn()),
	}
}
